Form Validation Support
Goals
Usage
WebFormElement
- validIfTrue: aBlock
- example: field validIfTrue: [:value | value asString = Date today year]
- isValid
WebForm
Error reporting
WebFormElement
- errorText: aString
- errorElement
Example (from included WebDemoApp)
ajaxValidationExample
| e field |
e := WebElement new.
e addTextH4: 'Instant validation example'.
e addText: 'Today''s year is: '.
field := e addInputFieldAspect: #year for: self size: 4.
field
onChangePost;
validIfTrue: [:value | value asInteger = Date today year];
errorText: 'Wrong!'.
e add: field errorElement. "this element will show error text in red near input field, if year is wrong"
^e